package cn.yl.fxboot;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

import cn.yl.fxboot.application.view.CustomSplash;
import cn.yl.fxboot.application.view.LoginStageView;
import cn.yl.fxboot.application.view.MainStageView;
import de.felixroske.jfxsupport.AbstractJavaFxApplicationSupport;
import javafx.scene.image.Image;
import javafx.stage.Stage;

@SpringBootApplication
@ComponentScan("cn.yl.fxboot.*")
public class FxApplication extends AbstractJavaFxApplicationSupport {
	static String proxyHost = "127.0.0.1";
	static String proxyPort = "1080";
	static boolean needProxy = false;

	public static void main(String[] args) {
		if(needProxy) {
			System.setProperty("http.proxyHost", proxyHost);
			System.setProperty("http.proxyPort", proxyPort);

			// 对https也开启代理
			System.setProperty("https.proxyHost", proxyHost);
			System.setProperty("https.proxyPort", proxyPort);
		}
		launch(FxApplication.class, MainStageView.class, new CustomSplash(), args);
	}

	@Override
	public void start(Stage stage) throws Exception {
		stage.setTitle("抖音助手");
		stage.setResizable(false);
		super.start(stage);
	}

	@Override
	public Collection<Image> loadDefaultIcons() {
		Image img32 = new Image("image/icon_32x32.jpg");
		Image img16 = new Image("image/icon_16x16.jpg");
		List<Image> iconList = new ArrayList<Image>();
		iconList.add(img16);
		iconList.add(img32);
		iconList.addAll(super.loadDefaultIcons());
		return iconList;
	}

}
